import pandas as pd
from sqlalchemy import create_engine
from utils.config import get_config


def evaluation_database():

    # 读取CSV文件
    df = pd.read_csv(f'../../data_csv/comment/evaluation.csv', header=0)
    df['product_id'] = df['product_id'].astype(str)

    config = get_config('../../server_config.ini')

    # 连接到PostgreSQL数据库
    engine = create_engine('postgresql://' + config['user'] + ':' + config['password'] + '@' +
                           config['host'] + ':' + config['port'] + '/' + config['database'])

    # 将数据写入数据库
    df.to_sql('evaluation', engine, if_exists='append', index=False)